import { Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd';
import { UtilService } from '../../../../core/util/util.service';
import { DispatchPlanService } from '../../dispatch-plan.service';
import { FetchService } from '../../../../core/net/fetch.service';
import { ActivatedRoute, Router } from '@angular/router';

const listTypeMap = {
    "0": "上报数据",
    "1": "指标查看",
    "2": "数据分解",

};

@Component({
  selector: 'app-mng-report-detail',
  templateUrl: './mng-report-detail.component.html',
  styleUrls: ['./mng-report-detail.component.scss']
})
export class MngReportDetailComponent implements OnInit {
    manageId = "";
    manageName = JSON.parse(localStorage.userInfo).manageName;
    paramsData = "";
    listType = "";
    listTypeTitle = "";
    /**
     *    1 - 表格 & 合计行（ 宁西公司 manageId === 1）
     *    2 - 普通表格
     */
    detailTableType = "normal";

    constructor(
        private util: UtilService,
        private dispatchService: DispatchPlanService,
        private fetchService: FetchService,
        private router: Router,
        private routerInfo: ActivatedRoute,
        private message: NzMessageService
    ) {
        this.listType = this.routerInfo.snapshot.queryParams['listType'] || '0';
        this.listTypeTitle = listTypeMap[this.listType];
        this.paramsData = this.routerInfo.snapshot.queryParams['paramsData'];
        this.manageId = this.routerInfo.snapshot.queryParams['manageId'] || JSON.parse(localStorage.userInfo).manageId;
        if (this.manageId === '1') {
            this.detailTableType = 'normal'; // 宁西公司
        } else { // 普通表格 （合并行）
            this.detailTableType = 'normal';
        }
    }

    ngOnInit() {

    }

    goBack(): void {
        this.router.navigate(['/dispatch-plan/month-plan'], {
            skipLocationChange: true,
            queryParams: {listType: this.routerInfo.snapshot.queryParams['listType']}
        });
    }
}
